package com.xxgc.mq.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.UUID;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/addOrder")
    public String addOrder(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id",String.valueOf(UUID.randomUUID()));
        //百分之九十的支付平台，如微信支付，支付宝支付，财付通支付等第三方接口，金额单位都是用的分，不是double类型
        map.put("money",952);
        rabbitTemplate.convertAndSend("order_exchange","order",map);
        return "下单成功";
    }

}
